#!/bin/bash
# See https://stackoverflow.com/questions/72725315/how-to-use-decode-stacktrace-sh
# To use decode_stacktrace.sh, you need to have CONFIG_DEBUG_INFO=y.
# NOTE: in recent kernels (>= v5.12) a multiple choice option for the DWARF
# version was added (CONFIG_DEBUG_INFO_DWARF{4,5,_TOOLCHAIN_DEFAULT}).
# So we need not explictly enable CONFIG_DEBUG_INFO, we can just set
# CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y, which will enable CONFIG_DEBUG_INFO.
#
# So to use this dump_stack.sh script, you need to run menuconfig and have
# CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y in your .config file.

source ./envsetup

if [[ -z "${OUT}" ]]; then
	OUT=$WS_LINUX/out-linux
fi

if [[ -z "$1" ]]; then
	echo "Please provide the log file."
	exit
fi

$PATH_LINUX/scripts/decode_stacktrace.sh $OUT/vmlinux $PATH_LINUX < $1
